﻿using PC.PickleJar.DataProviders;
using PC.PickleJar.Domain;
using PC.PickleJar.DummyData.Domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PC.PickleJar.DummyData.DataProviders
{
	internal class DummyDataProvider : IDataProvider
	{
		public SourceItemBase GetSourceItem(ItemKeyBase itemKey)
		{
			if (itemKey as DummyStoryKey == null)
			{
				throw new ArgumentException("itemKey must be of type DummyStoryKey");
			}


			DummyStoryKey storyKey = (DummyStoryKey)itemKey;
			DateTime dummyTimestamp;

			if (storyKey.Value % 2 == 0)
			{
				dummyTimestamp = DateTime.Now.Subtract(TimeSpan.FromDays(10000));
			}
			else
			{
				dummyTimestamp = DateTime.Now.Add(TimeSpan.FromDays(1));
			}

			DummyStory result =
				new DummyStory(
					new DummyStoryKey(storyKey.Value),
					dummyTimestamp);

			return result;
		}
	}
}
